package
{
	import com.jidolstar.astro.*;	
	import flash.display.Sprite;

	/**
	 * 세차운동 테스트
	 * @author Yongho, Ji
	 * @since 2009.05.12
	 */ 
	public class testPrecession extends Sprite
	{
		public function testPrecession()
		{
			super();
			
			trace( "================================ test Precession  ====================================");
			//-----------------------------------------------------
			// Astronomical Algorithms 2nd p.137
			//-----------------------------------------------------			
			var toJDE:Number = ALDate.date2JD( -214, 6, 30, 0, 0, 0 );
			var fromJDE:Number = ALConst.JD_J2000;
			var precession:ALPrecession = new ALPrecession( fromJDE, toJDE );
			var eclMat:ALMatrix3D = precession.getPrecessionOfEclMatrix();
			var eclLong:Number = 149.48194;
			var eclLat:Number = 1.76549;
			var eclVec:ALVector3D = new ALVector3D( eclLong * ALConst.D2R, eclLat * ALConst.D2R, 1, ALVector3D.COORDINATE_TYPE_SPHERICAL );
			var precEclVec:ALVector3D =  eclMat.multiply3x3ByVector3D( [eclVec] )[0];
			trace( "λ0 = " + eclVec.longitudeDegree ); //λ0 = 149.48194
			trace( "β0 = " + eclVec.latitudeDegree ); //β0 = 1.76549
			trace( "fromJDE = " + fromJDE ); //fromJDE = 2451545
			trace( "toJDE = " + toJDE ); //toJDE = 1643074.5
			trace( "λ = " + precEclVec.longitudeDegree ); //λ = 118.70416774860918
			trace( "β = " + precEclVec.latitudeDegree ); //β = 1.6153320060500687
			
			//-----------------------------------------------------
			// Astronomical Algorithms 2nd p.135
			//-----------------------------------------------------
			var RA:Number = ALHMS.HMS2FractionalHour( 2, 44, 11.986 ); //적경 2h 44m 11.986s
			var DE:Number = ALDMS.DMS2FractionalDegree( 49,13,42.48 ); //적위 49°13'42".48
			var pRA:Number = 0.03425;	//annual proper motion in right ascension [second]
			var pDE:Number = -0.0895;	//annual proper motion in declination [arcsecond]
			var fromDate:ALDate = new ALDate( ALConst.JD_J2000 );	//2000년 1월 1일 
			var toDate:ALDate = new ALDate( 2028, 11, 13.19 );	//2028년 11월 13.19일
			fromJDE = fromDate.JD;
			toJDE = toDate.JD;
			var julianYear:Number = ALTimeConverter.getJulianYear( fromJDE, toJDE ); //Julian Year
			var deltaRA:Number = pRA * julianYear;
			var deltaDE:Number = pDE * julianYear;
			var RA1:Number = RA + deltaRA / 3600;
			var DE1:Number = DE + deltaDE / 3600;
			precession = new ALPrecession( fromJDE, toJDE );
			var equVec:ALVector3D = new ALVector3D( RA1 * ALConst.H2R, DE1 * ALConst.D2R, 1, ALVector3D.COORDINATE_TYPE_SPHERICAL );
			var equMat:ALMatrix3D = precession.getPrecessionOfEquMatrix();
			var precEquVec:ALVector3D = equMat.multiply3x3ByVector3D( [equVec] )[0];
			trace( "------------------------------" );
			trace( "α0 = " + RA * ALConst.H2D ); //α0 = 41.04994166666666
			trace( "δ0 = " + DE); //δ0 = 49.22846666666667
			trace( "fromJDE = " + fromJDE ); //fromJDE = 2451545
			trace( "toJDE = " + toJDE ); //toJDE = 2462088.69
			trace( "Julian Year = " +julianYear); //28.86704996577671
			trace( "Δα = " + deltaRA ); //Δα = 0.9886964613278525
			trace( "Δδ = " + deltaDE ); //Δδ = -2.5836009719370154
			trace( "α0 + Δα = " + equVec.longitudeDegree ); //α0 + Δα = 41.05406123525553
			trace( "δ0 + Δδ = " + equVec.latitudeDegree ); //δ0 + Δδ = 49.22774899973002
			trace( "α = " + precEquVec.longitudeDegree + " = " + ALHMS.fractionalHour2HMS( precEquVec.longitudeHour ).toString("h","m","s",3)); //α = 41.5472125975129 = 02h46m11.331s
			trace( "δ = " + precEquVec.latitudeDegree + " = " + ALDMS.fractionalDegree2DMS( precEquVec.latitudeDegree ).toString());//δ = 49.34848211286583 = 49° 20’ 54”.54			
		}
		
	}
}